﻿define(function(require, exports, modules) {
	var $ = require('jquery');
	require("jqueryMobile");
	require("jquery.cookie");
	require("jqueryMore");
	require('swiper');
	var iScroll = require('iscroll');
	var Common = require('Common');
	var Common2 = require('Common2');
	var main_storage = window.localStorage;
	var myScroll, pullUpEl, pullUpOffset, generatedCount = 0;
	window.productList = {
		totalNum: 0,
		pageNum: 1,
		itemNum: 10, // 每次加载数据条数
		totalSize: 0,
		topSpeed: 3000, // 单张图片不自动滚动，0为不滚动
		isExternal: false, // 单张图片不可滑动，false为可以滑动
		newsPageNum: 1,
		newsStep: '',
		newsListData: [],
		newsIndex: 0,
		hasNewsResult: true,
		jifenUrl: '',
		yongjinUrl: '',
		brokerId: main_storage.getItem("userId"),
		init: function() {

			if(Common2.request("from") == "htmm" && !Common2.request("code")) {
				$("body").css("display", "none");
				localStorage.clear();
				var url = encodeURI(window.location.href + "&isFrom=transUrl");
				window.location.href = $.M.htmmUrl + "/connect/oauth2/authorize?client_id=ht2469204941705216&redirect_uri=" + url + "&response_type=code&state=STATE"
			}
			if(Common2.request("from") == "htmm" && Common2.request("province")) {
				localStorage.setItem("cityname", Common2.request("province"))
			}
			if(Common2.request("from") == "htmm" && Common2.request("code")) {
				$("body").css("display", "none");
				$.M.post({
						method: "/oAuth/auth",
						params: {
							code: Common2.request("code"),
							province: localStorage.getItem("cityname")
						},
						dataType: "json",
						success: function(data) {
							localStorage.setItem("from", "h5");
							if(data.result) {
								if(data.objValue) {
									localStorage.setItem("userToken", data.objValue.token);		
									localStorage.setItem("screenName",data.objValue.screenName);
									localStorage.setItem("loginType", "customer");
									productList.UserLogin(data);
								} else {
									if(data.paramMap && data.paramMap.province) {
										localStorage.setItem("cityId", data.paramMap && data.paramMap.province);
									}

									window.location.href = "propertyList.html?from=" + localStorage.getItem("from");
								}

							} else {
								productList.showMessges(data.value);
								setTimeout(function() {
									window.location.href = "propertyList.html?from=" + localStorage.getItem("from");
								}, 400)

							}
						},
						error: function(XMLHttpRequest, textStatus, errorThrown) {
							productList.showMessges(data.value);
						}
					},
					"0");

			}
			//判断是否呈现红包弹框
			productList.getCouponIsShow(function(data) {
				if(data.coupon_on_off1 == '1' && localStorage.getItem('notShowPageCoupon') != '1') {
					productList.showCoupon(data);
				}
				if(data.coupon_on_off2 == '1') {
					productList.showActivePop(data);
				} else {
					$(".draggable").css("display", "none")
				}
			});

			//			//微信绑定登陆
			//			Common.getUserIdByOpenId();
			// 判断是否出现城市三角图标
			Common.getAppVersion(function(data) {
				if(data.coupon_is_show == 1) {
					$(".chooseclassright, .chooseclassleft").css("width", "33.33%");
					$(".chooseclassright").css("display", "inline-block");
					main_storage.setItem("coupon_is_show", 1);
				} else {
					$(".isborder").css("border-right", "none");
				}
				if(data.coupon_on_off3 != 1) {
					$("#notice").css("display", "none");
				}

			});
			productList.getNotice();
			var fromFlag = Common2.Init($("#backLink"));
			if(fromFlag == "null") {
				fromFlag = eval(fromFlag);
			}
			if(!fromFlag) {
				if(!fromFlag) { // 如果没有标记，说明从微信来，需要去掉图片
					$("#backLink").addClass("titleLeft_trilateral_noicon");
				} else {
					$("#backLink").removeClass("titleLeft_trilateral_noicon");
					//					$("#backLink").bind("click", function() {
					//						window.location.href = "cityEntrance.html?currentCity=" + main_storage.getItem("cityname");
					//					});
				}
			} else {
				$("#backLink").removeClass("titleLeft_trilateral_noicon");
				//				$("#backLink").bind("click", function() {
				//					window.location.href = "cityEntrance.html?currentCity=" + main_storage.getItem("cityname");
				//				});
			}

			//			点击搜索进入搜索
			$("#iconTop1").bind("click", function() {
				window.location.href = "search.html?from=" + main_storage.getItem("from");
			});
			//			点击搜索进入搜索
			$("#J_img1").bind("click", function() {
				var is_login = localStorage.getItem("isLogined");
				if(is_login != 1) {
					window.location.href = "login.html?from=" + main_storage.getItem("from");
				} else {
					window.location.href = "signaward.html?from=" + main_storage.getItem("from");
				}

			});
			$(".couponContent .click_close").bind("click", function() {
				$(this).parent().parent().hide();
			});
			$("#J_img2").bind("click", function() {
				window.location.href = "previewBuilding.html?from=" + main_storage.getItem("from");
			});
			$("#loginTipToSign .gotoLogin").bind("click", function() {
				window.location.href = $(this).attr("href");
			});
			//			点击进入消息中心
			$("#iconTop2").bind("click", function() {
				window.location.href = "msgCenter.html?from=" + main_storage.getItem("from");
			});

			$(".hot-news .more").bind("click", function() {
				window.location.href = "hotNewsList.html?companyId=" + Common.storage.getItem("cityId") + "&from=" + Common.storage.getItem("from") + "&oldCompanyId=" + Common.storage.getItem("oldCompanyId");
			});

			$("#coupon").bind("click", function() {
				var is_login = localStorage.getItem("isLogined");
				if(is_login != 1) {
					$("#loginTipToSign").show();
					$("#loginTipToSign .gotoLogin").attr("href", "login.html?from=" + main_storage.getItem("from") + "&refer=myCouponList.html?from=" + Common2.request("from"));
				} else {
					window.location.href = "myCouponList.html?from=" + Common2.request("from");
				}
			});

			productList.loaded();
			productList.getBannerIsScroll(function(isScroll) {
				productList.getBanner(isScroll);

			});
			productList.getInfo(false);
			productList.sendIp();
			productList.queryList();
			productList.getUrlLink();
			//productList.isShowReceiveCoupon();
		},
		showMessges: function(messges) {
			$("#login_error_word").html(messges);
			$("#login_error").css("visibility", "visible");
			setTimeout('$("#login_error").css("visibility", "hidden")', 3000);
		},
		//获取是否呈现弹框操作
		getCouponIsShow: function(fn) {
			return;
			$.M.post({
				method: '/sys/getAppVersion?type=1',
				params: {},
				success: function(data) {
					data = eval('(' + data + ')');
					$(".icon_contain i").css("background", "url(" + data.paramMap.coupon_on_pic3 + ")  -3% 42% / 5.5rem no-repeat");
					//签到按钮是呈现
					data.paramMap.coupon_on_off4 != 1 ? $("#J_img1").css("display", "none") : "";
					!!fn && fn(data.paramMap);
				}
			}, "0");
		},
		//获取用户登录信息操作 
		UserLogin: function(data) {
			if(data.result) {
				var fromFrag = localStorage.getItem("from");
				if(fromFrag == "null") {
					fromFrag = eval(fromFrag);
				}
				if(data.objValue.dormantStatus == "1") { //该字段为1表示休眠状态
					localStorage.setItem("userId", data.objValue.id);
					window.location.href = "propertyList.html?from=" + localStorage.getItem("from");
				} else {
					localStorage.setItem("userId", data.objValue.id);
					localStorage.setItem("isLogined", "1");

					//设置需要检查休眠，行业，实名认证
					localStorage.setItem("needCheck", "1");
					if(data.paramMap.province) {
						localStorage.setItem("cityId", data.paramMap.province);
						window.location.href = "propertyList.html?from=" + localStorage.getItem("from") + '&companyId=' + data.paramMap.province
					} else {
						window.location.href = "propertyList.html?from=" + localStorage.getItem("from");
					}

				}
			} else {
				productList.showMessges(data.value);
			}
		},
		bindNewsHTML: function() {
			if(productList.newsIndex >= productList.newsListData.length) {
				productList.newsPageNum++;
				productList.newsIndex = 0;
				// if(productList.hasNewsResult){
				// 	productList.getNewsList();
				// } else {
				productList.bindNewsHTML();
				//}
			} else {
				var html = '';
				for(var i = 0; i < productList.newsStep; i++) {
					if(productList.newsListData[productList.newsIndex + i] != undefined) {
						html += '<div class="list-item" onclick="productList.goNewsDetail(\'' + productList.newsListData[productList.newsIndex + i].id + '\', \'' + productList.newsListData[productList.newsIndex + i].url + '\')"><span class="red-text">【热点】</span><span class="text">' + productList.newsListData[productList.newsIndex + i].title + '</span></div>';
					} else {
						html += '<div class="list-item"></div>';
					}
				}
				productList.newsIndex = productList.newsIndex + productList.newsStep;
				$(".hot-news-list").html(html);
				$(".hot-news-list .list-item").animate({
					width: '100%',
					opacity: '1'
				}, 300);

				if(productList.newsListData.length > productList.newsStep) {
					setTimeout(function() {
						productList.bindNewsHTML();
					}, 8000);
				}
			}
		},
		goNewsDetail: function(newsId, url) {
			if(url == 'null' || url == null || url == '') {
				main_storage.setItem("newsId", newsId);
				window.location.href = "noticeDetail.html";
			} else {
				main_storage.setItem("outLink", url);
				window.location.href = "outLink.html";
			}
		},
		queryList: function() {
			//			$.M.post({
			//				method: "/rest/building/queryBuildingCityByCompanyId",
			//				params: {
			//					"companyId": main_storage.getItem("cityId")
			//				},
			//				dataType: "json",
			//				success: function(data) {
			//					if (data.result) {
			//						var info = data.objValue;
			//						var html = '';
			//						$.each(info, function(i, item) {
			//							html += '<div class="citynamediv" id="' + item.id + '" onclick = "productList.changecityborder(this)">' + item.name + '</div>'
			//						});
			//						$(".citylist .greyRounddiv").html(html);
			//						html = "";
			//						$.each(info, function(i, item) {
			//							$.each(item.list, function(j, index) {
			//								html += '<div class="housenamediv" data-id="'+item.id+'" id="' + index.id + '" onclick="productList.changehouseborder(this)">' + index.name + '</div>'
			//							});
			//						});
			//						$(".houselist .greyRounddiv").html(html);
			//					} else {
			//						alert("获取城市列表失败");
			//					}
			//
			//				},
			//				error: function(XMLHttpRequest, textStatus, errorThrown) {
			//					productList.hideMsg();
			//				}
			//			}, "0");
		},
		getUrlLink: function() {
			//			$.M.post({
			//				method: "/sys/getSysCodeByType",
			//				params: {
			//					"type": "url_jump"
			//				},
			//				dataType: "json",
			//				success: function(data) {
			//					if (data.result) {
			//						for (var i = 0; i < data.objValue.length; i++) {
			//							if(data.objValue[i].codeKey == '0'){
			//								productList.jifenUrl = data.objValue[i].value;
			//							} else if (data.objValue[i].codeKey == '1'){
			//								productList.yongjinUrl = data.objValue[i].value;
			//							}
			//						}
			//					}
			//				},
			//				error: function(XMLHttpRequest, textStatus, errorThrown) {
			//					productList.hideMsg();
			//				}
			//			}, "0");
		},
		setrenzheng: function(type) {
			window.location.href = "recommendPage.html?companyId=" + Common.storage.getItem("cityId") + "&from=" + Common.storage.getItem("from") + "&oldCompanyId=" + Common.storage.getItem("oldCompanyId");
		},
		showcitylist: function() {
			$(".citylist").fadeToggle();
			$(".houselist").hide();
		},

		houselist: function() {
			$(".houselist").fadeToggle();
			$(".citylist").hide();
		},
		changecityborder: function(obj) {
			var $id = $(obj).attr('id');
			$('.houselist .greyRounddiv div').hide();
			$('.houselist .greyRounddiv div[data-id="' + $id + '"]').show();
			$(".citynamediv").css("border", "1px solid #DDDBDC")
			$(obj).css("border", "1px solid rgb(247,76,85)")
			$("#selectcity span").html($(obj).html());
			$(".citylist").fadeToggle();
		},
		changehouseborder: function(obj) {
			$(".housenamediv").css("border", "1px solid #DDDBDC")
			$(obj).css("border", "1px solid rgb(247,76,85)")
			$("#selecthouse span").html($(obj).html());
			productList.goHousePage($(obj).attr("id"));
			$(".houselist").fadeToggle();
		},
		getQueryString: function(name) { 
			var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");     
			var r = window.location.search.substr(1).match(reg);     
			if(r != null) return  unescape(r[2]);
			return null;
		},
		sendIp: function() {
			if(!!productList.getQueryString("fromSource")) {
				$.M.post({
					method: '/rest/log/addLog',
					params: {
						"fromSource": productList.getQueryString("fromSource"),
						"path": "propertyList.html"
					},
					success: function(data) {

					}
				}, "0");
			}
		},
		getCityLink: function() {
			window.location.href = "cityEntrance.html?currentCity=" + main_storage.getItem("cityname");
		},
		goHousePage: function(houseId) {
			main_storage.setItem("houseId", houseId);
			window.location.href = "shareHouse.html?companyId=" + Common.storage.getItem("cityId") + "&id=" + houseId + "&from=" + main_storage.getItem("from");
		},
		getNewsDetail: function(newsId, that, bUrl) {
			var $title = that.getAttribute('title')
			if(bUrl.indexOf("newRegisterPage") > 0) {
				window.location.href = "newRegisterPage.html";
				return;
			}
			if(bUrl.indexOf("myCouponList") > 0) {
				window.location.href = "myCouponList.html";
				return;
			}
			if(!!bUrl && bUrl != "null") {
				main_storage.setItem("outLink", bUrl);
				window.location.href = "outLink.html";
				return;
			}
			main_storage.setItem("newsId", newsId);
			window.location.href = "noticeDetail.html?newsId=" + newsId;
		},
		request: function(strParame) {
			var args = new Object();
			var query = location.href;
			var newQuery = query.substring(query.indexOf('?') + 1);
			var pairs = newQuery.split("&"); // Break at ampersand
			for(var i = 0; i < pairs.length; i++) {
				var pos = pairs[i].indexOf('=');
				if(pos == -1)
					continue;
				var argname = pairs[i].substring(0, pos);
				var value = pairs[i].substring(pos + 1);
				value = decodeURIComponent(value);
				args[argname] = value;
			}
			return args[strParame];
		},
		getInfo: function(isMore) {
			if($.M.openAjax) {
				productList.showMsg();

				var params = {
					'city': '',
					'area': '',
					'name': '',
					'isRecommand': '',
					'isHot': ''
				};

				var fromFlag = main_storage.getItem("from");
				if(fromFlag) {
					$.extend(params, {
						'fromApp': fromFlag,
						'remoteIp': $.cookie("H5ip"),
						'brokerId': main_storage.getItem("userId"),
						'province': main_storage.getItem("cityId")
					});
				} else {
					$.extend(params, {
						'fromApp': '2',
						'openId': $.cookie("openid"),
						'brokerId': main_storage.getItem("userId"),
						'province': main_storage.getItem("cityId")
					});
				}
				return;
				
				productList.hideMsg();
				$.M.post({
					method: '/rest/building/queryBuildingByProvinceId/' + productList.pageNum,
					params: params,
					success: function(data) {
						$("#pullUp").css("display", "block");
						productList.hideMsg();
						data = eval('(' + data + ')');
						if(data.result == true) {
							var html = '';
							productList.totalSize = data.objValue.totalSize;
							productList.totalNum = data.objValue.totalSize / productList.itemNum;
							var dataList = data.objValue.resultList;
							$.each(dataList, function(i, item) {
								html += '<div class="divDataList" onclick = "productList.goHousePage(\'' + item.id + '\')" id = "' + item.id + '">'
								html += '<div class="divPositionone">'
								html += '<div class="imgdivone">'
								html += '<img src="' + item.picsrc + '" class = "divPositionImgone">'
								html += '</div>'
								html += '<div class = "divIntroduceInformationone" ><span>' + item.name + '</span></div>'
								html += '<div class = "divIntroduceDetailone" ><span>' + item.salePoint + '</span></div>'
								html += '<div class="divFloorIntroduceone">'
								html += '<div class="floorDiv"><img src = "resource/css/images/propertyList/telIcon@2x.png"/><a href="tel:' + item.hotline + '" class = "floorSpan">' + item.hotline + '</a></div>'
								html += '</div>'
								html += '</div>'
								html += '</div>'
							});
							if(isMore == false) {
								$("#content").html(html);
							} else {
								$("#content").append(html);
							}
						} else {
							alert("获取楼盘列表失败");
						}
					},
					error: function(XMLHttpRequest, textStatus, errorThrown) {
						productList.hideMsg();
					}
				}, "0");
			}
		},
		//显示弹框
		showCoupon: function(data) {
			var html =
				'<div class="mask-tips">' +
				'<div class="mask-content">' +
				'<div class="mask-close"></div>' +
				'<img src="' + data.coupon_on_pic1 + '">' +
				'<div class="go-coupon">' +
				'</div>' +
				'<div>';
			$('body').append(html);
			$('.mask-tips .go-coupon').on('click', function() {

				var is_login = localStorage.getItem("isLogined");
				localStorage.setItem('notShowPageCoupon', '1');
				location.href = data.coupon_on_url2 + "?from=" + Common.getQueryString("from");

			});
			$('.mask-tips .mask-close').on('click', function() {
				$('.mask-tips').remove();
			});
		},
		//显示弹框
		showActivePop: function(data) {
			$(".draggable img").attr("src", data.coupon_on_pic2);
			$('.draggable img').on('click', function() {
				var is_login = localStorage.getItem("isLogined");
				localStorage.setItem('notShowPageCoupon', '1');
				location.href = data.coupon_on_url1 + "?from=" + Common.getQueryString("from");

			});
		},
		showMask: function(theme, msg) {
			$.mobile.showPageLoadingMsg(theme, msg);
			$(".mask_div").css("display", "block");
		},
		hideMask: function(theme, msg) {
			$.mobile.hidePageLoadingMsg(theme, msg);
			$(".mask_div").css("display", "none");
		},
		showMsg: function() {
			productList.showMask("c", "正在加载...");
		},
		hideMsg: function() {
			productList.hideMask("c", "正在加载...");
		},
		pullUpAction: function() {
			pullUpEl = document.getElementById('pullUp');
			pullUpOffset = pullUpEl.offsetHeight;
			setTimeout(function() {
				if((productList.totalNum) > (productList.pageNum)) {
					productList.pageNum += 1;
					productList.getInfo(true);
				} else {
					pullUpEl.className = '';
					pullUpEl.querySelector('.pullUpLabel').innerHTML = '共' + productList.totalSize + '条记录';
				}
				myScroll.refresh();
			}, 1000);
		},
		loaded: function() {
			pullUpEl = document.getElementById('pullUp');
			pullUpOffset = pullUpEl.offsetHeight;
			myScroll = new iScroll(
				'share_house_content', {
					checkDOMChanges: true,
					hScrollbar: false,
					vScrollbar: false,
					useTransition: true,
					onRefresh: function() {
						if(pullUpEl.className.match('loading')) {
							pullUpEl.className = '';
							pullUpEl.querySelector('.pullUpLabel').innerHTML = '上拉加载更多...';
						}
					},
					onScrollMove: function() {
						if(this.y < (this.maxScrollY - 20) && !pullUpEl.className.match('flip')) {
							pullUpEl.className = 'flip';
							pullUpEl.querySelector('.pullUpLabel').innerHTML = '松手开始更新...';
							this.maxScrollY = this.maxScrollY;
						} else if(this.y > (this.maxScrollY + 5) && pullUpEl.className.match('flip')) {
							pullUpEl.className = '';
							pullUpEl.querySelector('.pullUpLabel').innerHTML = '上拉加载更多...';
							this.maxScrollY = pullUpOffset;
						}
						if(this.y >= -20) {
							$('#backTop').css("display", "none");
						} else {
							$('#backTop').css("display", "block");
						}
					},
					onScrollEnd: function() {
						if(pullUpEl.className.match('flip')) {
							pullUpEl.className = 'loading';
							pullUpEl.querySelector('.pullUpLabel').innerHTML = '加载中...';
							productList.pullUpAction();
						}
					}
				});
			setTimeout(function() {
				document.getElementById('share_house_content').style.left = '0';
			}, 800);
		},
		getBannerIsScroll: function(fn) {
			$.M.post({
				method: '/sys/getAppVersion?type=1',
				params: {},
				success: function(data) {

					data = eval('(' + data + ')');

					!!fn && fn(data.paramMap.banner_on_off);
				}
			}, "0");
		},
		getBanner: function(isScroll) { // 日志详情请求的接口
			productList.showMask("c", "正在加载...");
			if($.M.openAjax) {
				$.M.post({
					method: "/rest/news/queryBannersByProv",
					params: {
						"type": "",
						"city": $.M.baseCity,
						'provincesId': main_storage.getItem("cityId")
						// "fa35dcd0755b4c9a94ed553af08c1aab"
					},
					success: function(data) {
						productList.hideMask("c", "正在加载...");
						data = eval('(' + data + ')');

						var banners = $(".swiper-slide");

						// 判断是否是一张图，一张不滚动
						var topImgIsFrist = true;
						$.each(data, function(i, item) {
							if(topImgIsFrist) {
								$(".swiper-slide img").attr("title", item.title);
								$(".swiper-slide img").attr("onclick", 'productList.getNewsDetail(\'' + item.newsId + '\',this,\'' + item.bUrl + '\')');

								$(banners[0]).children().attr("src", item.picsrc);
								$(banners[1]).children().attr("src", item.picsrc);
								$(banners[2]).children().attr("src", item.picsrc);
								productList.topSpeed = 0;
								productList.isExternal = true;
								topImgIsFrist = false;
							} else {
								if(isScroll == '1') {
									productList.topSpeed = 3000;
								} else {
									productList.topSpeed = 0;
								}
								productList.isExternal = false;
							}
						});
						productList.initSwiper(); // 渲染swiper

						var imageIndex = 0;

						var topImgIsFrist2 = true;
						$.each(data,
							function(i, item) {

								var imgPath = "";
								if(item.picsrc != null && item.picsrc != undefined && item.picsrc != null) {
									imgPath = item.picsrc;
								}
								if(topImgIsFrist2 == false) {
									TabScrollTop.tabsSwiper.appendSlide('<img title="' + item.title + '" onclick="productList.getNewsDetail(\'' + item.newsId + '\',this,\'' + item.bUrl + '\');" src="' + imgPath + '" />', 'swiper-slide');
								} else {
									topImgIsFrist2 = false;
								}
							});
						productList.setHeight();

						// setTimeout("productList.resetImg()", 20);

					},
					error: function(XMLHttpRequest, textStatus, errorThrown) {
						productList.hideMask("c", "正在加载...");
					}
				}, "0");
			}
		},
		//公告跳转详情页
		goNewsDetail: function(newsId) {

			main_storage.setItem("newsId", newsId);
			window.location.href = "noticeDetailApp.html";

		},
		//
		//			textScroll: function() {
		//				// 滚动步长(步长越大速度越快)
		//				var step_len = 60;
		//				var this_obj = $("#scrolllayer");
		//				var child = this_obj.children();
		//				var this_width = this_obj.width();
		//				var document = $("#scrollmessage span");
		//				var child_width = 0;
		//
		//				document.length > 0 && document.map(function(index, item) {
		//					child_width += $(item).text().length * 14 + 100;
		//				})
		//				$("#scrollmessage").css("width", child_width - 100)
		//				var continue_speed = undefined; // 暂停后恢复动画速度
		//				// 初始文字位置
		//				child.css({
		//					left: this_width
		//				});
		//
		//				// 初始动画速度speed
		//				var init_speed = (child_width + this_width) / step_len * 1000;
		//
		//				// 滚动动画
		//				function scroll_run(continue_speed) {
		//					var speed = (continue_speed == undefined ? init_speed : continue_speed);
		//					child.animate({
		//						left: -child_width + 300
		//					}, speed, "linear", function() {
		//						$(this).css({
		//							left: this_width
		//						});
		//						scroll_run();
		//					});
		//				}
		//
		//				// 启动滚动
		//				scroll_run();
		//			},
		//公告
		getNotice: function() {
			productList.showMask("c", "正在加载...");
			$.M.post({
				method: "/rest/news/queryHotNewsByProv/1",
				params: {
					curPageNum: 1,
					pageSize: 10,
					companyId: main_storage.getItem("cityId"),
					type: 1,
					isNotice: 1
				},
				success: function(data) {
					var item = JSON.parse(data).objValue.resultList;
					var html = '';
					for(var i = 0; i < item.length; i++) {
						$("#scrollmessage ul").append("<li onclick=productList.goNewsDetail('" + item[i].id + "')>" + item[i].title + "</li>")
					}

					var marqueesHeight = 29; //高度
					var stopscroll = false;
					var scrollElem = document.getElementById("scrolllayer");
					with(scrollElem) {
						style.width = 500; //宽度
						style.height = marqueesHeight;
						style.overflow = 'hidden';
						noWrap = true;
					}

					scrollElem.onmouseover = new Function('stopscroll = true');
					scrollElem.onmouseout = new Function('stopscroll = false');
					var preTop = 0;
					var currentTop = 0;
					var stoptime = 0;
					var leftElem = document.getElementById("scrollmessage");
					scrollElem.appendChild(leftElem.cloneNode(true));
					scrollElem.scrollTop = 0;
					setInterval(function() {
						if(stopscroll) return;
						currentTop += 1;
						if(currentTop == 30) { //滚动距离
							stoptime += 1;
							currentTop -= 1;
							if(stoptime == 220) { //停顿时间
								currentTop = 0;
								stoptime = 0;
							}
						} else {
							preTop = scrollElem.scrollTop;
							scrollElem.scrollTop += 1;
							if(preTop == scrollElem.scrollTop) {
								scrollElem.scrollTop = 0;
								scrollElem.scrollTop += 1;
							}
						}
					}, 15); //滚动速度

				}

			}, "0");

		},

		initSwiper: function() {
			if(!TabScrollTop.tabsSwiper) {
				TabScrollTop.tabsSwiper = $('#swiper-container-top').swiper({
					pagination: '#pagination-top',
					createPagination: true,
					onlyExternal: productList.isExternal,
					speed: 1000,
					autoplay: productList.topSpeed,
					loop: true,
					onSlideChangeStart: function() {},
					onSlideChangeEnd: function() {
						TabScrollTop.tabsSwiper.startAutoplay();
					}
				});
				TabScrollTop.bindEvent();
			}
		},
		setHeight: function() {
			var wWidth = $(window).width();
			var imgHeight = $("#swiper-container-top .swiper-slide img").height();
			// 284×964
			imgHeight = wWidth * 81 / 196;
			$("#swiper-container-top .swiper-wrapper").css("height",
				imgHeight + "px");
			$("#swiper-container-top .swiper-wrapper .swiper-slide").css("height",
				imgHeight + "px");
			$("#swiper-container-top .swiper-wrapper .swiper-slide").css("width",
				wWidth + "px");
			// $("#swiper-container-top .swiper-slide img").css("max-height",
			// imgHeight + "px");
			$("#swiper-container-top .swiper-slide img").css("max-width",
				wWidth + "px");
		},
		resetImg: function() {
			var imgList = $("#swiper-container-top .swiper-slide img");
			var imgDivList = $("#swiper-container-top .swiper-wrapper .swiper-slide");
			for(var i = 0; i < imgList.length; i++) {
				var imgObj = $(imgList[i]);
				var imgDivObj = $(imgDivList[i]);
				if(imgObj.height() > 0) {
					var ptop = (imgDivObj.height() - imgObj.height()) / 2;
					imgObj.css("margin-top", (ptop + "px"));
				}
			}
		},
		isShowReceiveCoupon: function() {
			if(true) {
				var html = '<div class="mask_bg"><img class="receiveCoupon" src="resource/css/images/yaoqingzhuce@2x.png"></div>'
				$('body').append(html);
				$('body').on('click', '.receiveCoupon', function() {
					window.location.href = 'receiveCoupon.html';
				})
			}
		}
	};
	var TabScrollTop = {
		tabsSwiper: null,
		bindEvent: function() {
			$(window).resize(function() {
				setTimeout("productList.setHeight()", 20);
			});
		}
	}
	var registerScroll = null;
	$(document).bind("pageshow", function(e) {
		var id = e.target.id;
		if("share_house_page" == id) {
			productList.init();
		}
	});
	document.addEventListener('touchmove', function(e) {
		e.preventDefault();
	}, false);

	$('#backTop').click(function(event) {
		$('#scrollWrap').css("transform", "translateY(0px)")
	});

	$(document).ready(function() {
		//  $.M.post({
		// 	method: '/rest/msg/getMyUnreadMsgNum',
		// 	params: {
		// 		'id':productList.brokerId
		// 	},
		// 	success: function(data) {
		// 		data = eval('(' + data + ')');
		// 		if((data.objValue)>0){
		// 			$("#isMsg").css("display","block")
		// 		}

		// 	}

		// }, "0");

	});

});